﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BLL;
namespace 健身房管理
{
    public partial class mModify : Form
    {
        Point mouseOff;//鼠标移动位置变量
        bool leftFlag;//标签是否为左键


        public int id = 0;
        huiyuanBLL hyb = new huiyuanBLL();
        public mModify()
        {
            InitializeComponent();
        }

        private void mModify_Load(object sender, EventArgs e)
        {
            xgjiazai();
        }

        public void xgjiazai()
        {
            DataTable dt = hyb.MmodifyShow(id);
            if (dt.Rows.Count > 0)
            {
                this.txtname.Text = dt.Rows[0]["uname"].ToString();
                this.txtmail.Text = dt.Rows[0]["mail"].ToString();
                this.txtsex.Text = dt.Rows[0]["sex"].ToString();
                this.mqingja.Text = dt.Rows[0]["leave"].ToString();
                this.cardtime.Text = dt.Rows[0]["cartime"].ToString();
                this.cardnum.Text = dt.Rows[0]["carnum"].ToString();
            }
            else
            {
                MessageBox.Show("没有值进入");
            }
        }

        private void guna2Button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void guna2Button2_Click(object sender, EventArgs e)
        {
            string name = txtname.Text;
            string mail = txtmail.Text;
            string sex = txtsex.Text;
            string mqingja1 = mqingja.Text;
            int carnum = int.Parse(cardnum.Text);
            int cardtimes =int.Parse( cardtime.Text);
            bool b1 = hyb.mModifyupdata(name,mail,sex, mqingja1, carnum,cardtimes,id);
            if (b1)
            {
                MessageBox.Show("修改成功");
            }
            else
            {
                MessageBox.Show("修改失败");
            }
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void mModify_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                mouseOff = new Point(-e.X, -e.Y);
                leftFlag = true;
            }
        }

        private void mModify_MouseUp(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
                leftFlag = false;//释放鼠标后标注为False
            }
        }

        private void mModify_MouseMove(object sender, MouseEventArgs e)
        {

            if (leftFlag)
            {
                Point mouseSet = Control.MousePosition;
                mouseSet.Offset(mouseOff.X, mouseOff.Y);//设置移动后的位置
                Location = mouseSet;
            }
        }
    }
}
